#!/bin/sh

if [ -z "$1" ];then
	echo "Error: no interface specified"
	exit 1
fi

#ID=`echo $1 | sed 's/tap//g'`
ID=`echo $1 | cut -d "-" -f 3`
if [ -z "$ID" ]; then
	echo "Error: interface name $1"
	exit 1
fi

BRIDGE=qemunet$ID
if ! brctl show | grep $BRIDGE> /dev/null; then 
	brctl addbr $BRIDGE
fi

ifconfig $BRIDGE 10.1.$ID.1 netmask 255.255.255.0

ip link set $1 up
brctl addif $BRIDGE $1


